home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Express Pd: GALORE
/
Express Pd Galore - The Amiga PD & Shareware CD (1994)(Express Pd)[!][Amiga-CD32-CDTV].iso
/
productivity
/
term
/
termmisc.asm
< prev
next >
Wrap
Assembly Source File
|
1993-07-16
|
3KB
|
151 lines
**
** termMisc.asm
**
** Miscellaneous assembly language routines.
**
** Copyright © 1990-1993 by Olaf `Olsen' Barthel & MXM
** All Rights Reserved
**
include "exec/types.i"
include "exec/tasks.i"
include "exec/execbase.i"
*--------------------------------------------------------------------------
CALL macro
xref _LVO\1
jsr _LVO\1(a6)
endm
*--------------------------------------------------------------------------
csect text,0,0,1,2
*--------------------------------------------------------------------------
xdef _SPrintf
xdef _VSPrintf
xdef _Atol
xdef _StackReport
*--------------------------------------------------------------------------
_SPrintf:
movem.l a2/a3/a6,-(sp) ; Save registers
move.l 4+12(sp),a3 ; Get destination buffer
move.l 8+12(sp),a0 ; Get format string
lea 12+12(sp),a1 ; Get arguments
lea stuffchar(pc),a2 ; Get formatting routine
move.l _SysBase(a4),a6 ; Get ExecBase
CALL RawDoFmt ; Format the string
movem.l (sp)+,a2/a3/a6 ; Restore registers
rts
*--------------------------------------------------------------------------
_VSPrintf:
movem.l a2/a3/a6,-(sp)
move.l 4+12(sp),a3
move.l 8+12(sp),a0
move.l 12+12(sp),a1
lea stuffchar(pc),a2
move.l _SysBase(a4),a6
CALL RawDoFmt
movem.l (sp)+,a2/a3/a6
rts
stuffchar:
move.b d0,(a3)+
rts
*--------------------------------------------------------------------------
*
* A tiny replacement for Atol(), implemented through StrToLong.
*
*--------------------------------------------------------------------------
_Atol: move.l a0,d1 ; Save argument
movem.l d2/a6,-(sp) ; Save registers
pea.l 0 ; Push a zero on the stack
lea.l (sp),a0 ; Get a pointer to the value
move.l a0,d2 ; Get it into a convenient register
move.l _DOSBase(a4),a6 ; Get DOSBase
CALL StrToLong ; Convert the string
tst.l d0
bgt.b 1$ ; Did we get anything sensible?
addq #4,sp ; Fix the stack
moveq #0,d0 ; Clear the result
movem.l (sp)+,d2/a6 ; Restore registers
rts
1$ move.l (sp)+,d0 ; Get the conversion result
movem.l (sp)+,d2/a6 ; Restore registers
rts
*--------------------------------------------------------------------------
*
* A routine to return the amount of stack space currently
* in use. Quite useful for debugging purposes.
*
*--------------------------------------------------------------------------
_StackReport:
move.l a6,-(sp) ; Save library base
move.l _SysBase(a4),a6 ; Get SysBase
move.l ThisTask(a6),a0 ; We want to check ourselves
move.l TC_SPUPPER(a0),d0 ; Get the stack upper limit
sub.l sp,d0 ; Subtract the current stack pointer
subq #8,d0 ; Don't forget the remaining junk
move.l (sp)+,a6 ; Restore library base
rts
*--------------------------------------------------------------------------
*
* These two lines are actually to make SLINK believe that some kind
* of startup code will clear the Data/BSS segment before running the
* main program. Since this is no longer necessary with Kickstart 2.x
* these two lines will save quite some disk space.
*
*--------------------------------------------------------------------------
lea __BSSBAS,a0
move.l #__BSSLEN,d0
*--------------------------------------------------------------------------
csect __MERGED
xref _DOSBase
xref _SysBase
xref __BSSBAS
xref __BSSLEN
end